package com.esri.core.map.popup;

import com.esri.core.internal.util.d;
import com.esri.core.io.EsriServiceException;
import java.io.StringWriter;
import org.achartengine.internal.a;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class PopupMediaInfo {
    String a;
    String b;
    MEDIA_TYPE c;
    PopupMediaValue d;

    /* loaded from: classes.dex */
    public enum MEDIA_TYPE {
        IMAGE,
        PIECHART,
        BARCHART,
        COLUMNCHART,
        LINECHART;

        public static MEDIA_TYPE fromString(String str) {
            MEDIA_TYPE[] values;
            if (str == null) {
                return null;
            }
            for (MEDIA_TYPE media_type : values()) {
                if (str.equalsIgnoreCase(media_type.toString())) {
                    return media_type;
                }
            }
            return null;
        }
    }

    public String getTitle() {
        return this.a;
    }

    public void setTitle(String str) {
        this.a = str;
    }

    public String getCaption() {
        return this.b;
    }

    public void setCaption(String str) {
        this.b = str;
    }

    public MEDIA_TYPE getType() {
        return this.c;
    }

    public void setType(MEDIA_TYPE media_type) {
        this.c = media_type;
    }

    public PopupMediaValue getValue() {
        return this.d;
    }

    public void setValue(PopupMediaValue popupMediaValue) {
        this.d = popupMediaValue;
    }

    public static PopupMediaInfo fromJson(JsonParser jsonParser) throws Exception {
        String text;
        if (!d.c(jsonParser)) {
            throw new EsriServiceException("This response cannot be parsed.");
        }
        PopupMediaInfo popupMediaInfo = new PopupMediaInfo();
        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            String currentName = jsonParser.getCurrentName();
            jsonParser.nextToken();
            if (a.b.equals(currentName)) {
                if (jsonParser.getCurrentToken() != JsonToken.VALUE_NULL) {
                    popupMediaInfo.a = jsonParser.getText();
                }
            } else if ("caption".equals(currentName)) {
                if (jsonParser.getCurrentToken() != JsonToken.VALUE_NULL) {
                    popupMediaInfo.b = jsonParser.getText();
                }
            } else if ("type".equals(currentName)) {
                if (jsonParser.getCurrentToken() != JsonToken.VALUE_NULL && (text = jsonParser.getText()) != null) {
                    popupMediaInfo.c = MEDIA_TYPE.fromString(text);
                }
            } else if ("value".equals(currentName)) {
                popupMediaInfo.d = PopupMediaValue.fromJson(jsonParser);
            } else {
                jsonParser.skipChildren();
            }
        }
        return popupMediaInfo;
    }

    public String toJson() throws Exception {
        StringWriter stringWriter = new StringWriter();
        JsonGenerator a = d.a(stringWriter);
        a.writeStartObject();
        String str = this.a;
        if (str != null) {
            a.writeStringField(a.b, str);
        }
        String str2 = this.b;
        if (str2 != null) {
            a.writeStringField("caption", str2);
        }
        MEDIA_TYPE media_type = this.c;
        if (media_type != null) {
            a.writeStringField("type", media_type.toString().toLowerCase());
        }
        if (this.d != null) {
            a.writeFieldName("value");
            a.writeRawValue(this.d.toJson());
        }
        a.writeEndObject();
        a.close();
        return stringWriter.toString();
    }

    public int hashCode() {
        String str = this.b;
        int hashCode = ((str == null ? 0 : str.hashCode()) + 31) * 31;
        String str2 = this.a;
        int hashCode2 = (hashCode + (str2 == null ? 0 : str2.hashCode())) * 31;
        MEDIA_TYPE media_type = this.c;
        int hashCode3 = (hashCode2 + (media_type == null ? 0 : media_type.hashCode())) * 31;
        PopupMediaValue popupMediaValue = this.d;
        return hashCode3 + (popupMediaValue != null ? popupMediaValue.hashCode() : 0);
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && getClass() == obj.getClass()) {
            PopupMediaInfo popupMediaInfo = (PopupMediaInfo) obj;
            String str = this.b;
            if (str == null) {
                if (popupMediaInfo.b != null) {
                    return false;
                }
            } else if (!str.equals(popupMediaInfo.b)) {
                return false;
            }
            String str2 = this.a;
            if (str2 == null) {
                if (popupMediaInfo.a != null) {
                    return false;
                }
            } else if (!str2.equals(popupMediaInfo.a)) {
                return false;
            }
            if (this.c != popupMediaInfo.c) {
                return false;
            }
            PopupMediaValue popupMediaValue = this.d;
            if (popupMediaValue == null) {
                if (popupMediaInfo.d != null) {
                    return false;
                }
            } else if (!popupMediaValue.equals(popupMediaInfo.d)) {
                return false;
            }
            return true;
        }
        return false;
    }

    public String toString() {
        return "PopupMediaInfo [Title=" + this.a + ", Caption=" + this.b + ", Type=" + this.c + ", Value=" + this.d + "]";
    }
}
